﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SRS.Encryption;
using SRS;

namespace SRSConsole
{
    class Program
    {
        static void Main(string[] args)
        {
            String plain = "cisitu lama 3c/160b cisitu lama 3c/160b cisitu lama 3c/160b";
            String key   = "rezanachmadrezanac";
            byte[] plainByte = Encoding.ASCII.GetBytes(plain);
            byte[] keyByte = Encoding.ASCII.GetBytes(key);
            byte[] res;

            // ECB
            ECB ecb = new ECB();
            res = ecb.Encrypt(keyByte, plainByte);
            Console.WriteLine("Cipher " + Encoding.ASCII.GetString(res));

            res = ecb.Decrypt(keyByte, res);
            Console.WriteLine("Plain " + Encoding.ASCII.GetString(res));


            // CBC
            CBC cbc = new CBC();
            res = cbc.Encrypt(keyByte, plainByte);
            Console.WriteLine("Cipher " + Encoding.ASCII.GetString(res));

            res = cbc.Decrypt(keyByte, res);
            Console.WriteLine("Plain " + Encoding.ASCII.GetString(res));

            
            // CFB
            CFB cfb = new CFB();
            res = cfb.Encrypt(keyByte, plainByte, 11);
            Console.WriteLine("Cipher " + Encoding.ASCII.GetString(res));

            res = cfb.Decrypt(keyByte, res,11);
            Console.WriteLine("Plain " + Encoding.ASCII.GetString(res));


            // OFB
            OFB ofb = new OFB();
            res = ofb.Encrypt(keyByte, plainByte, 14);
            Console.WriteLine("Cipher " + Encoding.ASCII.GetString(res));

            res = ofb.Decrypt(keyByte, res, 14);
            Console.WriteLine("Plain " + Encoding.ASCII.GetString(res));
        }
    }
}
